﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Paltop_v0._1.UI.Admin
{
    public partial class ExtensionManagement : System.Web.UI.Page
    {
        public string ExtensionRow = "";
        public string jsFunctionArray = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            
            Paltop_DatabaseLayer.PaltopDatabaseEntities pde = new Paltop_DatabaseLayer.PaltopDatabaseEntities();
            var extensions = from E in pde.FileExtentions
                             select E;
            int rowNum = 0;
            foreach (var item in extensions)
            {
                rowNum++;
                ExtensionRow += "<tr id=\"tr_" + item.FileExtentionID + "\"><td>" + rowNum + "</td><td class=\"extTitle\">" + item.Title + "</td><td>" + item.JSFunction + "</td><td>" + item.Description + "</td><td>" +
                    "<a href=\"#\" onclick=\"Edit(" + item.FileExtentionID + ")\">edit</a></td><td><a href=\"#\" onclick=\"disable(" + item.FileExtentionID + ")\">disable</a></td></tr>";
            }

            var jsFunctions = from S in pde.SYSMainSettings
                              where S.Title == "Extentions"
                              select S;
            System.Xml.Linq.XElement ExtensionSetting = System.Xml.Linq.XElement.Parse(jsFunctions.First().Setting);
            
            foreach (var item in ExtensionSetting.Elements("Extention"))
            {
                jsFunctionArray += item.Element("JSFunction").Value + ',';
            }
            jsFunctionArray = jsFunctionArray.Substring(0, jsFunctionArray.Length - 1);          
        }
    }
}